import request from '@/utils/request'

export interface DataSourceConfigVO {
  id: number | undefined
  name: string
  url: string
  username: string
  password: string
  createTime?: Date
}

// 新增数据源配置
export const createDataSourceConfig = (data: DataSourceConfigVO) => {
  return request({
    url: '/infra/data-source-config/create',
    method: 'POST',
    data,
  })
}

// 修改数据源配置
export const updateDataSourceConfig = (data: DataSourceConfigVO) => {
  return request({
    url: '/infra/data-source-config/update',
    method: 'PUT',
    data,
  })
}

// 删除数据源配置
export const deleteDataSourceConfig = (id: number) => {
  return request({
    url: `/infra/data-source-config/delete?id=${id}`,
    method: 'DELETE',
  })
}

// 查询数据源配置详情
export const getDataSourceConfig = (id: number) => {
  return request({
    url: `/infra/data-source-config/get?id=${id}`,
    method: 'GET',
  })
}

// 查询数据源配置列表
export const getDataSourceConfigList = () => {
  return request({
    url: '/infra/data-source-config/list',
    method: 'GET',
  })
}
